<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <title>系统登录</title>
    <link rel="stylesheet" href="__YI__/layui/css/layui.css">
    <link rel="stylesheet" href="__YI__/css/login.css">
    <script src="__YI__/layui/layui.js"></script>
</head>
<body>
    <div id="main">
        <form id="form" name="form" class="layui-form" action="" method="post"><!---->
            <div class="login">
                <div class="login-box login-header">
                    <h2>会员管理中心</h2>
                </div>
                <div class="layui-form-item">
                    <label class="layadmin-user-login-icon layui-icon layui-icon-username" for="uname"></label>
                    <input type="text" id="unameId" name="uname" placeholder="请输入用户名" autocomplete="off" class="layui-input">
                </div>
                <div class="layui-form-item">
                    <label class="layadmin-user-login-icon layui-icon layui-icon-password" for="password"></label>
                    <input type="password" id="passwordId" name="password" placeholder="请输入密码" autocomplete="off" class="layui-input">
                </div>
                <div class="layui-form-item">
                    <label class="layadmin-user-login-icon layui-icon layui-icon-vercode" for="code"></label>
                    <input type="text" id="codeId" name="code" placeholder="请输入验证码" autocomplete="off" class="layui-input">
                </div>
                <div class="layui-form-item">
                    <img id="verifyimg" class="verifyimg" src="{:captcha_src()}">
                    <p><a id="reloadverify" href="javascript:void(0);">看不清？换一张试试。</a></p>
                </div>
                
                <div class="layui-form-item">
	                    <input type="checkbox" name="islogin" lay-skin="switch" lay-text="ON|OFF">
	                    <span class="switch-label">自动登录</span>
	                
                </div>
                <div class="layui-form-item">
                    <button class="layui-btn" lay-submit lay-filter="login">登录</button>
                    <button type="reset" class="layui-btn layui-btn-primary">重置</button>
                </div>
            </div>
        </form>
    </div>
</body>
<script type="text/javascript">
    layui.use(['form','jquery'], function(){
        var $ = layui.jquery,
            form = layui.form;
        // 刷新验证码
        var verifyimg = $(".verifyimg").attr("src");
        function reloadverify() {
            if( verifyimg.indexOf('?')>0){
                $(".verifyimg").attr("src", verifyimg+'&random='+Math.random());
            }else{
                $(".verifyimg").attr("src", verifyimg.replace(/\?.*$/,'')+'?'+Math.random());
            }
        }
        $("#verifyimg").click(reloadverify);
        $("#reloadverify").click(reloadverify);
        //监听提交
        form.on('submit(login)', function(data){
            $.ajax({
                "url":'',
                "data":data.field,
                "dataType":'text',
                "type":'post',
                success:function (data) {
                    data = JSON.parse(data);
                    if (data.status == 1){
                        layer.msg("登录成功",{
                            time:700,
                            end:function(){
                                location.href = "/";//跳转到首页
                            }
                        })
                    }else{
                        layer.msg(data.msg);//给出错误提示
                        reloadverify();
                    }
                },
                error:function(){
                    layer.msg("登录错误,连接服务器失败...");
                }
            })
            return false;
        });
    });
</script>
</html>